import { asyncRoutes, constantRoutes } from '@/router'
export default {
  namespaced: true,
  state: {
    routes: constantRoutes || []
  },
  mutations: {
    setRoutes(state, otherRoutes) {
      state.routes = [
        ...constantRoutes,
        ...otherRoutes,
        { path: '*', redirect: '/404', hidden: true }
      ]
    }
  },
  actions: {
    filterRoutes(context, menus) {
      const otherRoutes = asyncRoutes.filter(item => menus.includes(item.children[0].name))
      context.commit('setRoutes', otherRoutes)
      return otherRoutes
    }
  }
}
